/**
 * Created by Administrator on 2017/9/16 0016.
 */
$(document).ready(function () {
    var dh = $(this).outerHeight();
    $(".main").height(dh*0.9+"px");
    $(".footer").height(dh*0.1+"px");

    var $_userName_ipt = $("input[name=userName]");
    var $_password_ipt = $("input[name=password]");
    var $yzm = $("input[name=yzm]");
    /*var $_userType_ipt = $("select[name=type]");*/
    var $login_form = $("#login-form");
    var $msg = $("#msg");
    var $u_clear = $(".u-clear");

    $login_form.on('submit',function(e){
        e.preventDefault();
        var _userName = $_userName_ipt.val();
        var _password = $_password_ipt.val();
        /*var _userType = $_userType_ipt.val();*/
        var flg = true;
        if(! _userName){
            $msg.text("请输入用户名");
            $msg.parent().removeClass("hide");
            flg = flase;
        } else if(! _password){
            $msg.text("请输入密码");
            $msg.parent().removeClass("hide");
            flg = flase;
        }
        if(flg ){
            this.submit();
        }else{
            return flg;
        }
    })

    $_userName_ipt.on('input',function(){
        var $this = $(this);
        if($this.val()){
            $this.next().removeClass("hide");
            if($msg.text()== "请输入用户名"){
                $msg.parent().addClass("hide");
            }
        }else{
            $this.next().addClass("hide");
        }
    })

    $_password_ipt.on('input',function(){
        var $this = $(this);
        if($this.val()){
            $this.next().removeClass("hide");
            if($msg.text()== "请输入密码"){
                $msg.parent().addClass("hide");
            }
        }else{
            $this.next().addClass("hide");
        }
    })

   /* $_userType_ipt.on('change',function(){
        if($(this).val && $("#msg").text()== "请选择用户类型"){
            $msg.parent().addClass("hide");
        }
    })*/


    for(var i =0 ;i<$u_clear.length;i++){
        $u_clear.on('click',function () {
            var $this = $(this);
            $this.prev().val("");
            $this.addClass("hide")
        })
    };


    var $chImage = $(".chImage");
    $chImage.on('click',function(){
        $(this).attr("src","/kaptcha.jpg?t=" + new Date().getTime());
    })

})